﻿using DC2010.Objects.Base;
using DC2010.Objects.Data;

namespace DC2010.Conditions
{
    public class C_IsPartyFacing : ConditionLogic
    {
        public C_IsPartyFacing(ConditionData cd):base(cd)
        {
            ShortName = "Is party facing";
            LongName = "Checks what direction is party facing.";
        }

        public override bool CheckCondition(BaseObject aInvoker, BaseObject aTarget)
        {
            bool bresult = false;
            if ((Root.I.GameSystem!=null)&&(Root.I.GameSystem.Party != null))
            {
                string pValue = Data.Params.Find(A => A.Key == "FACING").Value;

                switch (pValue)
                {
                    case "NORTH":
                        {
                            if (Root.I.GameSystem.Party.Location != null)
                                bresult = Root.I.GameSystem.Party.Location.Facing == Directions.North;
                            break;
                        }
                    case "WEST":
                        {
                            if (Root.I.GameSystem.Party.Location != null)
                                bresult = Root.I.GameSystem.Party.Location.Facing == Directions.West;
                            break;
                        }
                    case "SOUTH":
                        {
                            if (Root.I.GameSystem.Party.Location != null)
                                bresult = Root.I.GameSystem.Party.Location.Facing == Directions.South;
                            break;
                        }
                    case "EAST":
                        {
                            if (Root.I.GameSystem.Party.Location != null)
                                bresult = Root.I.GameSystem.Party.Location.Facing == Directions.East;
                            break;
                        }

                }


                HandleEffects(bresult, aInvoker, aTarget);
                return bresult;
            }

            return false;
        }
    }
}
